package com.wk.springbootlearn.common.config;

import com.wk.springbootlearn.common.aop.JWTInterceptor;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Setter
@Component
@ConfigurationProperties(value = "jwt")
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    private String[] ignorePath;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                .excludePathPatterns(ignorePath)//登录接口不用于token验证
                .addPathPatterns("/**"); //其他非登录接口都需要进行token验证
    }
}